package com.tx.server;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpRequest;
import org.slf4j.LoggerFactory;

/**
 * @author dengguoxing
 * @date 2019/10/31
 * description
 **/
public abstract class WebSocketListener {

    protected static org.slf4j.Logger logger = LoggerFactory.getLogger(WebSocketListener.class);

    public void onOpen(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
        logger.info("ws open");
    }

    public void onMessage(ChannelHandlerContext ctx, String msg) throws Exception {
        logger.info("ws msg: {}", msg);
    }

    public void onClosed(ChannelHandlerContext ctx) throws Exception {
        logger.info("ws closed");
    }

    public void onFailure(ChannelHandlerContext ctx, Throwable t) throws Exception {
        logger.info("ws failure");
    }

    public void onHeartBroken(ChannelHandlerContext ctx) throws Exception {
        logger.info("ws heart broken");
    }
}
